﻿@using NC.Cather
@using NC.Infrastructure
@using NC.Service
@model NC.Infrastructure.Domain.Identity.Person
@{
    ViewBag.Title = "Details";
}


<section class="content">
    <div class="row">
        <div class="col-md-3">
            <!-- Profile Image -->
            <div class="box box-primary">
                <div class="box-body box-profile">
                    <img class="profile-user-img img-responsive img-circle" style="width: 100px; height: 100px;" src="@Model.Image" alt="User profile picture">
                    <h3 class="profile-username text-center">@Model.TickName</h3>
                    <p class="text-muted text-center">@Model.Name</p>

                    <ul class="list-group list-group-unbordered">
                        <li class="list-group-item">
                            <b>入学时间</b> <a class="pull-right">@(Model.InSchoolTime)年份</a>
                        </li>
                        <li class="list-group-item">
                            <b>学号</b> <a class="pull-right">@Model.SchoolNumber</a>
                        </li>
                        <li class="list-group-item">
                            <b>角色</b> <a class="pull-right">@(EnumDictionary.RoleDictionary[(int) Model.Role])</a>
                        </li>
                        <li class="list-group-item">
                            <b>网站列表</b><a class="pull-right" href="@Url.Action("Index","Target",new {personId=Model.Id})">列表</a>
                        </li>
                        <li class="list-group-item">
                            <b>自我描述</b> <a class="pull-right"></a>
                        </li>
                    </ul>
                    <p>@Model.Description</p>
                </div>
            </div>
        </div>
        <div class="col-md-9">
            <div class="nav-tabs-custom">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#activity" data-toggle="tab">申请网站</a></li>
                </ul>
                <div class="tab-content">
                    <div class="active tab-pane" id="activity">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>
                                        <span>网站图标</span>
                                    </th>
                                    <th>
                                        <span>网站地址</span>
                                    </th>
                                    <th style="max-width: 200px;">
                                        <span>备注</span>
                                    </th>
                                    <th>
                                        <span>AppId</span>
                                    </th>
                                    <th>
                                        操作
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                @{
                                    string imagePath = "";
                                    var targets = (List<Target>) ViewBag.targets;
                                }
                                @foreach (var item in targets)
                                {
                                    <tr>
                                        <td>
                                            @{
                                                imagePath = File.Exists(item.FavirateIco) ? SystemConfig.DefaultImagePath : item.FavirateIco;
                                                <img src="@imagePath" style="width: 40px; height: 40px; border-radius: 50%;" />
                                            }

                                        </td>
                                        <td>
                                            <a href="@item.Url">@item.Name</a>
                                        </td>
                                        <td>
                                            @item.Description
                                        </td>
                                        <td>
                                            @item.AppId
                                        </td>
                                        <td>
                                            <div class="btn-group">
                                                <a href="@Url.Action("Index", "ApiRecord", new {targetId = item.Id})" class="btn btn-primary">接口记录</a>
                                                <a href="@Url.Action("ToContentParams", "Person", new {targetId = item.Id,personId=ViewBag.id})" class="btn btn-primary">文章内容管理</a>
                                                <a href="@Url.Action("Index","UrlList",new {targetId=item.Id})" class="btn btn-success">管理</a>
                                                <div onclick="stopTarget('@item.Id')" class="btn btn-success">停用</div>
                                            </div>
                                        </td>
                                    </tr>
                                                }
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<script type="text/javascript">
    function stopTarget(id) {
        confirm(function () {
            $.ajax({
                url: "@Url.Action("StopTarget","Target")" + "?id=" + id,
                type: "post",
                success: function (data) {
                    if (data.status == 0) {
                        showError(data.msg);
                    } else {
                        showSuccess("停用成功！");
                    }
                },
                error: function (error) {
                    showError("接口调用失败");
                }
            });
        }, "确定要停用此网站？");
    }
    function deleteTarget(id) {
        confirm(function () {
            $.ajax({
                url: "@Url.Action("DeleteTarget","Target")" + "?id=" + id,
                type: "post",
                success: function (data) {
                    if (data.status == 0) {
                        showError(data.msg);
                    } else {
                        showSuccess("删除成功！");
                    }
                },
                error: function (error) {
                    showError("接口调用失败");
                }
            });
        }, "确定要删除此网站？");
    }
    function loadtTargetDetails(targetId) {

    }
</script>